package org.ccay.demo.grid.service;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

import org.ccay.core.base.BatchVO;
import org.ccay.core.base.PageVO;
import org.ccay.core.base.PagedResult;
import org.ccay.core.exception.ApplicationException;
import org.ccay.demo.grid.vo.GridVO;

/**
 * 
 * IGrid测试Service接口
 */
@Path("/grid")
@Produces("application/json")
public interface IGridService {
	
	/**
	 * 通过条件分页查询信息
	 * @author chaowangbang
	 * @since 2013-4-15
	 * @param queryGrid
	 * @param pageVO
	 * @return
	 */
	@GET
	@Path("/list/page/{pageSize}/{curPage}/{orderBy}")
	PagedResult<GridVO> findPagedDemoList(@QueryParam("") GridVO queryGrid, @PathParam("") PageVO pageVO);
	
	/**
	 * 通过条件滚动查询信息
	 * @author chaowangbang
	 * @since 2012-11-7
	 * @param queryGrid
	 * @param taxis 排序字段，如：age desc或者age asc
	 * @param pageVO
	 * @return
	 */
	@GET
	@Path("list/ranged/{startIndex}/{endIndex}/{orderBy}/{totalRows}")
	PagedResult<GridVO> findRangeDemoList(@QueryParam("") GridVO queryGrid, @PathParam("") PageVO pageVO);
	
	/**
	 * 滚动加载分页
	 * @author chaowangbang
	 * @since 2012-11-8
	 * @param queryGrid
	 * @param pageVO
	 * @param totalRows 总行数
	 * @return
	 */
	@GET
	@Path("list/range/{startIndex}/{endIndex}/{totalRows}")
	PagedResult<GridVO> findRangedDemoList(@QueryParam("") GridVO queryGrid, @PathParam("") PageVO pageVO, @QueryParam("sort") String taxis, @PathParam("totalRows") int totalRows);
	
	/**
	 * 增加数据	
	 * @author chaowangbang
	 * @since 2012-11-8
	 * @param newGrid
	 * @throws ApplicationException
	 */
	@POST
	@Path("create")
	void createDemo(GridVO newGrid) throws ApplicationException;
	
	/**
	 * 批量增加数据
	 * @author chaowangbang
	 * @since 2012-11-12
	 * @param newGrids
	 * @throws ApplicationException
	 */
	void createDemos(List<GridVO> newGrids) throws ApplicationException;
	
	/**
	 * 批量删除数据	
	 * @author chaowangbang
	 * @since 2012-11-12
	 * @param existedGrids
	 * @throws ApplicationException
	 */
	void deleteDemos(List<GridVO> existedGrids) throws ApplicationException;
	
	/**
	 * 批量修改数据	
	 * @author chaowangbang
	 * @since 2012-11-12
	 * @param existedGrids
	 * @throws ApplicationException
	 */
	void updateDemos(List<GridVO> existedGrids) throws ApplicationException;
	
	/**
	 * 批量操作数据	
	 * @author chaowangbang
	 * @since 2012-11-12
	 * @param batchItems
	 * @throws ApplicationException
	 */
	@PUT
	@Path("batch")
	void batchOperation(BatchVO<GridVO> batchItems) throws ApplicationException;
	
}
